package com.xbongbong.paas.enums;

import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 自定义报表三项的选择
 * @author 梁鲁江
 * @version v1.0
 * @date 2019/2/27 16:12
 * @since v1.0
 */
@Getter
public enum BIDoubleSelectEnum {
    /**
     * key 是  XbbRefTypeEnum的两项组合，中间加   "  _"
     */
    //合同开头  合同、机会、客户
    CONTRACT_CUSTOMER(XbbRefTypeEnum.CONTRACT.getCode()+"_"+XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), "", "", Arrays.asList(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode())),
    CONTRACT_OPP(XbbRefTypeEnum.CONTRACT.getCode()+"_"+XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), "", "", Arrays.asList(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode())),
    //工单  工单、合同、客户
    WORK_ORDER_CONTRACT(XbbRefTypeEnum.WORK_ORDER.getCode()+"_"+XbbRefTypeEnum.CONTRACT.getCode(), "", "", Arrays.asList(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode())),
    WORK_ORDER_CUSTOMER(XbbRefTypeEnum.WORK_ORDER.getCode()+"_"+XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), "", "", Arrays.asList(XbbRefTypeEnum.CONTRACT.getCode())),
    //采购退货  采购退货、 采购退货出库单、 采购合同
    //RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE.getCode()+"_"+XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), "", "", Arrays.asList(XbbRefTypeEnum.PURCHASE.getCode())),
    //RETURNED_PURCHASE_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode()+"_"+XbbRefTypeEnum.PURCHASE.getCode(), "", "", Arrays.asList(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode())),




    ;
    /**
     * 枚举值   XbbRefTypeEnum  code_code
     */
    private final String code;

    /**
     * 枚举信息--中文名称
     */
    private final String name;

    /**
     * 枚举描述 --英文名称
     */
    private final String alias;
    /**
     *  可选择关联
     */
    private final List<Integer> team;

    BIDoubleSelectEnum(String code, String name, String alias, List<Integer> team) {
        this.code = code;
        this.name = name;
        this.alias = alias;
        this.team = team;
    }

    /**
     * 根据枚举值 获取可选
     * @param code  枚举值
     * @return  可选的集合
     */
    public static List<Integer> getTeamListByCode(String code) {
        List<Integer>  list = new ArrayList<>();
        for (BIDoubleSelectEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                list.addAll(cacheCode.getTeam());
            }
        }
        return list;
    }
}
